package com.gxa.system_setting.service.impl;

import com.gxa.common.R;

import com.gxa.common.entity.system_settings.HorsemanSalary;
import com.gxa.system_setting.mapper.HorsemanSalaryMapper;
import com.gxa.system_setting.service.HorsemanSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HorsemanSalaryServiceImpl implements HorsemanSalaryService {

    @Autowired
    private HorsemanSalaryMapper horsemanSalaryMapper;

    @Override
    public R queryHorsemanSalaryList(Integer currentPage, Integer pageSize) {
        R r=new R();
        Integer startPage=(currentPage-1)*pageSize;
        List<HorsemanSalary> horsemanSalaryList=horsemanSalaryMapper.selectHorsemanSalaryList(startPage, pageSize);
        r.setCode(200);
        r.setMessage("查询成功");
        r.setData(horsemanSalaryList);
        return r;
    }

    @Override
    public R updateById(HorsemanSalary horsemanSalary) {
        R r=new R();
        int i = horsemanSalaryMapper.updateHorsemanSalary(horsemanSalary);
        r.setCode(200);
        r.setMessage("修改成功");
        return r;
    }

    @Override
    public R stopOrUse(Long horseman_salary_id, Long flag) {
        R r=new R();
        int i=horsemanSalaryMapper.stopOrUse(horseman_salary_id,flag);
        r.setCode(200);
        r.setMessage("启用或禁用成功");
        return r;
    }

    @Override
    public R queryHorseByScopeOrStatus(String scope_application, Long status) {
        R r=new R();
        List<HorsemanSalary> horsemanSalaryList=horsemanSalaryMapper.queryHorseByScopeOrStatus(scope_application,status);
        r.setCode(200);
        r.setMessage("条件查询成功");
        r.setData(horsemanSalaryList);
        return r;
    }

    @Override
    public R insertHorse(HorsemanSalary horsemanSalary) {
        R r=new R();
        horsemanSalary.setStatus(1);
        int i=horsemanSalaryMapper.insertHorse(horsemanSalary);
        r.setCode(200);
        r.setMessage("添加成功");
        return r;
    }
}
